<?php
    $old_user = "";
    $old_ip = "";
    $skn = "";
    $msg = "";
    $error = "";

    if (isset($_REQUEST['user_name']) && 
        isset($_REQUEST['ip_address']) &&
        $_REQUEST['user_name'] != "" &&
        $_REQUEST['ip_address'] != "") 
    {

        global $db_manager;
        $old_user = $_REQUEST['user_name'];
        $old_ip = $_REQUEST['ip_address'];
        
        $xremots = new x_remots($db_manager);
        
        // Check IP address
        if ($xremots->is_valid_ip($old_ip)) {
        	
            $i = $xremots->delete_remot($old_user, $old_ip);
            if ($i > 0) {
                $msg = $labels["LBL_REMOTEIP_DELETED"];
                $skn = "showmessage";           
                //Firewall rules should be restarted
                $xadmin = new x_admin($db_manager);
                $xadmin->set_reboot_mark();
	            // Log action
	            $xlog = new x_log($db_manager);
	            $xlog->add_msg(sprintf($log_msg["LOG_MSG_DELIP"], $old_ip, $old_user));
            } elseif ($i == 0) {
                $msg = $labels["LBL_REMOTEIP_NOTFOUND"];
                $skn = "delip";           
            } else {
                $msg = $db_manager->db_error();
                $skn = "delip";           
            }
            
        } else {
            $msg = $labels["LBL_WRONG_IPADDRESS"];
            $skn = "delip";
        }       
        
    } else {
        $skn = "delip";
        $msg = "";
    }

    $Skinner=new Skinner();
    $Skinner->setSkin($skins_path.$skn);
    $Skinner->registerVariable("files_path", $files_path);
    $Skinner->registerVariable("admin_root", $admin_root);    
    $Skinner->registerVariable("message", $msg);
    $Skinner->registerVariable("user_name_value", $old_user);
    $Skinner->registerVariable("ip_address_value", $old_ip);
    $Skinner->registerVariable("lbl_del_remote_ip", $labels["LBL_DEL_REMOTE_IP"]);
    $Skinner->registerVariable("lbl_username", $labels["LBL_USER"]);
    $Skinner->registerVariable("lbl_ipaddress", $labels["LBL_IPADDRESS"]);
    $Skinner->registerVariable("lbl_ok", $labels["LBL_OK"]);
    
    $content=$Skinner->doSubstitution_FAST();

?>
